package com.alkaid.user.controller;

import com.alkaid.commons.controller.BaseController;
import com.alkaid.commons.param.user.SmsParam;
import com.alkaid.commons.utils.JsonResult;
import com.alkaid.user.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Kylin
 */
@RestController
@RequestMapping("/api/user")
public class SmsController extends BaseController {

    private SmsService smsService;

    @Autowired
    public void setSmsService(SmsService smsService) {
        this.smsService = smsService;
    }

    @PostMapping("/sms")
    public JsonResult<Void> sms(@Validated SmsParam smsParam) {
        smsService.sendSmsCode(smsParam.getMobile(), smsParam.getType());
        return new JsonResult<>(200, null, "验证码发送成功");
    }
}
